﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace ICeFramework.Win.UI.FSWatcher
{
    [Serializable,
    XmlRoot("WatcherItemCollection")]
    public class FSWatcherItemCollection
    {
        private string _rootDir;
        #region public string RootDir
        /// <summary>
        /// Get/Sets the RootDir of the FSWatcherItemCollection
        /// </summary>
        /// <value></value>
        [XmlElement]
        public string RootDir
        {
            get { return _rootDir; }
            set { _rootDir = value; }
        }
        #endregion

        private List<FSWatcherItem> _list;
        #region public IList<FSWatcherItem> Items
        /// <summary>
        /// Get/Sets the Items of the FSWatcherItemCollection
        /// </summary>
        /// <value></value>
        [XmlArray("Items")]
        public List<FSWatcherItem> Items
        {
            get { return _list; }
            set { _list = value; }
        }
        #endregion

        public FSWatcherItemCollection()
        {
            _list = new List<FSWatcherItem>();
        }

        public bool Add(FSWatcherItem item)
        {
            if (!_list.Contains(item))
            {
                _list.Add(item);
                return true;
            }
            return false;
        }

        public void Clear()
        {
            _list.Clear();
        }

        public bool Contains(FSWatcherItem item)
        {
            return _list.Contains(item);
        }

        public void CopyTo(FSWatcherItem[] array, int arrayIndex)
        {
            _list.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return _list.Count; }
        }

        public bool Remove(FSWatcherItem item)
        {
            return _list.Remove(item);
        }
    }
}
